home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload Trio 2 / Shareware Overload Trio Volume 2 (Chestnut CD-ROM).ISO / dir31 / gus_prog.zip / GUS_SPEC.TXT next >
Text File  |  1993-01-19  |  10KB  |  259 lines

  1.                    ┌───────────────────────────────┐
  2.                    │  Gravis Ultrasound Tech Specs │
  3.                    └───────────────────────────────┘
  4.                            The Unofficial Dox
  5.  
  6.                          Written December, 1992
  7.                 By Tran of Renaissance and Joshua Jensen
  8.  
  9. OK, folks, here it is.  This is the programming information that Gravis
  10. didn't and won't give you any time soon.  These dox have been obtained
  11. through long hours of debug sessions and experimentation.
  12.  
  13. Let's clear up some things that have been debated in comp.sys.ibm.pc.soundcard
  14. for quit sometime now:
  15.  
  16.   ~ The GUS can play 32 mono samples at once, fully pannable through 16
  17.     different positions.
  18.  
  19.   ~ This is still a bit unclear.  The SDK says that samples have to be
  20.     32-byte aligned in memory.  I've been following this.  Maybe that is
  21.     not the case, though, and I haven't tested it.
  22.  
  23. Credits:  Tran came up with the initial information about programming the
  24. card.  Josh documented it and included actual assembly language information
  25. in this archive on how it works.  It's relatively simple, but some things are
  26. unclear and are explained here in the dox and in the code.
  27.  
  28. ────────┬─────────────────────────────────────────────────────────────────────
  29. Methods │
  30. ────────┘
  31. @DELAY = (in byte 300h)*7
  32.  
  33. Description:  All this function does is give a short idle wait for the card
  34.               to do whatever processing it needs to.
  35. ──────────────────┬───────────────────────────────────────────────────────────
  36. Probe Ultra Sound │
  37. ──────────────────┘
  38.   out BASE+103h, 4Ch
  39.   out BASE+105h, 0
  40.   @DELAY
  41.   @DELAY
  42.   out BASE+103h, 4Ch
  43.   out BASE+105h, 1
  44.   Poke Data Byte   Loc:   0h, Byte: AA    ; Don't think this HAS to be an AA.
  45.   Poke Data Byte   Loc: 100h, Byte: 55    ; Don't think this is needed.
  46.   Peek Data Byte   Loc:   0h
  47.   Store Byte
  48.   out BASE+103h, 4Ch
  49.   out BASE+105h, 0
  50.   Restore Byte
  51.   Is it AA?  If so, then we have found a GUS.
  52.  
  53. ──────────────────────────────────────────────────┬───────────────────────────
  54. Test for amount of memory installed on UltraSound │
  55. ──────────────────────────────────────────────────┘
  56.   Poke Data Byte   Loc: 40000h, Byte: AA
  57.   Peek Data Byte   Loc: 40000h
  58.   Is it an AA?  If not, then there is 256k of DRAM.  Exit.
  59.   Poke Data Byte   Loc: 80000h, Byte: AA
  60.   Peek Data Byte   Loc: 80000h
  61.   Is it an AA?  If not, then there is 512k of DRAM.  Exit.
  62.   Poke Data Byte   Loc: C0000h, Byte: AA
  63.   Peek Data Byte   Loc: C0000h
  64.   Is it an AA?  If not, then there is 768k of DRAM.  Exit.
  65.   Poke Data Byte   Loc: 0FFFFFh, Byte: AA
  66.   Peek Data Byte   Loc: 0FFFFFh
  67.   Is it an AA?  If not, then there is 1024k of DRAM.  Exit.
  68.  
  69. Description:  Poke these bytes on the boundaries of 256k, 512k, 768k, and
  70.               1024k.  If the memory isn't there, then it won't return what
  71.               is poked.
  72. ───────────────┬──────────────────────────────────────────────────────────────
  73. Peek Data Byte │
  74. ───────────────┘
  75.   out BASE+103h, 43h
  76.   out BASE+104h, low word address
  77.   out BASE+103h, 44h
  78.   out BASE+105h, high byte address
  79.   in  BASE+107h, INBYTE
  80.  
  81. Description:  The card's memory can be from 00000h to fffffh.  INBYTE is the
  82.               byte value returned from the card that was at that memory
  83.               location.
  84. ───────────────┬──────────────────────────────────────────────────────────────
  85. Poke Data Byte │
  86. ───────────────┘
  87.   out BASE+103h, 43h
  88.   out BASE+104h, low word address
  89.   out BASE+103h, 44h
  90.   out BASE+105h, high byte address
  91.   out BASE+107h, OUTBYTE
  92. ────────────────────┬─────────────────────────────────────────────────────────
  93. Set Voice Frequency │
  94. ────────────────────┘
  95.   out BASE+102h, voice number
  96.   out BASE+103h, 1
  97.   out BASE+104h, word frequency number (actual frequency / 19.0579083837)
  98.  
  99. Description:  Tran thought he'd give you the exact value :)  Dividing by 19
  100.               will give enough accuracy for the task, though.
  101. ──────────────────┬───────────────────────────────────────────────────────────
  102. Set Voice Balance │
  103. ──────────────────┘
  104.   out BASE+102h, voice number
  105.   out BASE+103h, 0ch
  106.   out BASE+105h, byte balance (0-0fh)
  107.  
  108. Description: The Balance byte can range from 0 to 15.  0 is far left,
  109.              15 is far right, and 7 is right in the middle.
  110. ─────────────────┬────────────────────────────────────────────────────────────
  111. Set Voice Volume │
  112. ─────────────────┘
  113.   out BASE+102h, voice number
  114.   out BASE+103h, 9
  115.   out BASE+104h, word volume value (0-0ffffh, log ... not linear)
  116. ──────────────┬───────────────────────────────────────────────────────────────
  117. Set Loop Mode │
  118. ──────────────┘
  119.   out BASE+102h, voice number
  120.   out BASE+103h, 80h
  121.   in  BASE+105h, TEMP
  122.   out BASE+103h, 0
  123.   out BASE+105h, (TEMP & 0e7h) or MODE
  124.  
  125. Description:  This is not really necessary.  Actually, the Set Loop Mode and
  126.               Stop Voice Immediately could be one function.
  127. ───────────────────────┬──────────────────────────────────────────────────────
  128. Stop Voice Immediately │
  129. ───────────────────────┘
  130.   out BASE+102h, voice number
  131.   out BASE+103h, 80h
  132.   in  BASE+105h, TEMP
  133.   out BASE+103h, 0
  134.   out BASE+105h, (TEMP & 0dfh) | 3
  135.   @DELAY
  136.   out BASE+103h, 0
  137.   out BASE+105h, (TEMP & 0dfh) | 3
  138.  
  139. Description:  Dunno why the extra delay and duplicated code is there.
  140. ────────────────────┬─────────────────────────────────────────────────────────
  141. Start Voice Playing │
  142. ────────────────────┘
  143.   out BASE+102h, voice number
  144.   out BASE+103h, 0ah
  145.   out BASE+104h, word BEGIN >> 7
  146.   out BASE+103h, 0bh
  147.   out BASE+104h, word BEGIN << 9
  148.   out BASE+103h, 2
  149.   out BASE+104h, word START >> 7
  150.   out BASE+103h, 3
  151.   out BASE+104h, word START << 9
  152.   out BASE+103h, 4
  153.   out BASE+104h, word END >> 7
  154.   out BASE+103h, 5
  155.   out BASE+104h, word END << 9
  156.   out BASE+103h, 0
  157.   out BASE+105h, MODE & 0fch
  158.  
  159. ────────────────────┬─────────────────────────────────────────────────────────
  160. Read Voice Location │
  161. ────────────────────┘
  162.   out BASE+102h, voice number
  163.   out BASE+103h, 8ah
  164. ; in  BASE+104h, low byte TEMP0
  165. ; in  BASE+105h, high byte TEMP0
  166.   in  BASE+104h, word TEMP0
  167.   out BASE+103h, 8bh
  168. ; in  BASE+104h, low byte TEMP1
  169. ; in  BASE+105h, high byte TEMP1
  170.   in  BASE+104h, word TEMP1
  171.  
  172.     LOC = ((TEMP0 << 7) | (TEMP1 >> 9)) & 0xfffff
  173.  
  174. Note: Word read at BASE+104h seems to work same as sequential byte reads
  175.       from BASE+104h then BASE+105h.
  176. ──────────────────────────────────────────────────────────────────────────────
  177.  
  178. ──────┬───────────────────────────────────────────────────────────────────────
  179. Ports │ As you can see, there are a lot of blanks to be filled.  Hope Gravis
  180. ──────┘ will take a hint soon.
  181.  
  182. BASE - write only, mix control
  183. ┌───────────────────────────────┐
  184. │ 7 3 6 3 5 3 4 3 3 3 2 3 1 3 0 │
  185. └───────────────────────────────┘
  186.   ?   ?   ?   ?   ?   3   3   3
  187.                       3   3   @ 0 = Line in on.  1 = Line in off.
  188.                       3   @DDDD 0 = Output on.   1 = Output off.
  189.  
  190.  
  191.                       @DDDDDDDD 0 = Mic in off.  1 = Mic in on.   ???
  192.  
  193.  
  194.  
  195. BASE+102h - Active voice select (byte port)
  196.  
  197. BASE+103h - command port (byte port)
  198.   Bitmap so far:
  199.   ZDDDBDDDBDDDBDDDBDDDBDDDBDDDBDDD?
  200.   3 7 3 6 3 5 3 4 3 3 3 2 3 1 3 0 3
  201.   @DBDADBDADBDADBDADBDADBDADBDADBDY
  202.     3   3   ?   ?   3   3   3   3
  203.     3   3           3   3   3   3
  204.     3   3           3   3   @DDD4
  205.     3   3           3   @DDDDDDDE Command for voice
  206.     3   3           @DDDDDDDDDDDY
  207.     3   @DDDDDDDDDDDDDDDDDDDDDDDD Command for card.
  208.     @DDDDDDDDDDDDDDDDDDDDDDDDDDDD Read from voice.
  209.  
  210.    0h - write voice mode (loop and data type)           - byte on 105h
  211.   ZDDDBDDDBDDDBDDDBDDDBDDDBDDDBDDD?
  212.   3 7 3 6 3 5 3 4 3 3 3 2 3 1 3 0 3     Designated as MODE through dox
  213.   @DBDADBDADBDADBDADBDADBDADBDADBDY
  214.     ?   ?   ?   3   3   3   3   3
  215.                 3   3   3   3   @ Voice On/Off (If both set to 0, voice on.)
  216.                 3   3   3   @DDDD Voice On/Off (If both set to 1, voice off.)
  217.                 3   3   @DDDDDDDD 0 = 8 bit data.  1 = 16 bit data.
  218.                 3   @DDDDDDDDDDDD 0 = No loop.     1 = Loop Sample.
  219.                 @DDDDDDDDDDDDDDDD 0 = Go forward.  1 = Go backward.
  220.    1h - voice frequency                                 - word on 104h
  221.    2h - loop start location / 80h                       - word on 104h
  222.    3h - loop start location << 9                        - word on 104h
  223.    4h - loop end location / 80h                         - word on 104h
  224.    5h - loop end location << 9                          - word on 104h
  225.    9h - voice volume                                    - word on 104h
  226.   0ah - voice location / 80h                            - word on 104h
  227.   0bh - voice location << 9                             - word on 104h
  228.   0ch - voice balance                                   - byte on 105h
  229.   0eh - Unsure.  Has something to do with turning       - byte on 105h
  230.           stereo on and off.  See U_Reset for an
  231.           example of usage.
  232.   43h - low word of DRAM address                        - word on 104h
  233.   44h - high byte of DRAM address                       - byte on 105h
  234.   4Ch - Unsure exactly of what this does                - byte on 105h
  235.           However, a 1 must be output to BASE+105h for
  236.           the card to do memory writes.  At least, that's
  237.           the only way I could get it to work.
  238.   80h - read voice mode                                 - byte on 105h
  239.   8ah - read voice location                             - bytes on 104h, 105h
  240.   8bh - read voice location                             - bytes on 104h, 105h
  241.  
  242. Notes:  Any >= 80h plus a number might be the read mode of the value - 80h.
  243.         In other words, to read the voice volume (this is untested), you'd
  244.         output an 89h through BASE+103h and then read BASE+105h.
  245.  
  246. BASE+104h - word writes/reads
  247. BASE+105h - byte writes/reads
  248.  
  249. ──────┬───────────────────────────────────────────────────────────────────────
  250. Notes │
  251. ──────┘
  252. To stop an instrument when the sample ends (not immediately), change its
  253. loop type to 'no loop'.
  254.  
  255. If you are making a lot of changes to just ONE voice, the
  256. OUT BASE+102h, Channel needs only to be done once.
  257.  
  258.  
  259.